<template>
  <!--性别比列-->
  <div  >
    <div>
      <div class="header">
       员工性别统计

      </div>
      <div>
        <div id="back6" ></div>
      </div>

    </div>
  </div>
</template>

<script>
import axios from "axios";
import {mapState} from 'vuex'
export default {
  name: "Sex",
  data(){
    return{

      sexDateX:[
        /*{value:3,name:'男'},
        {value:3,name:'女'}*/
      ]
    }
  },
  computed:{
    ...mapState(['sexData'])
  },
  methods:{
    //对接数据
   getsexDate(){

  /* let {data:res} = await axios.get('http://132.232.110.185/personnelManagement/dataStatistics/employeeSexStatistics')
           console.log(res.data)*/
     axios({
       url: 'http://132.232.110.185/personnelManagement/dataStatistics/employeeSexStatistics',
       method: 'get',

     }).then((response) => {


         this.$store.dispatch('setSexData',response.data.data)



     })




    },
    getSex(){
      const myChart = this.$echarts.init(document.getElementById("back6"))//引入到盒子
      const option = {
        title: {
          text: '在职员工性别统计',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '性别比列',
            type: 'pie',
            radius: '50%',
            data: this.sexData,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);

    }

  },

  mounted() {
    this.getSex()
    this.getsexDate()
  },
  created() {
    this.getsexDate()
    console.log(this.sexData)
  }

}
</script>

<style scoped>
.header{
  width: 100%;
  height: 74px;
  border-bottom: 1px solid rgba(0,0,0,0.3);
  padding-left:12px ;
  line-height: 74px;
  font-size: 18px;
}
#back6{
  width: 100%;
  text-align: center;
  height: 700px;
  line-height: 700px;
  margin:22px auto 0;

}
</style>


